package com.lucenten.collect.config.entity;

import cn.quevo.common.entity.DoEntity;
import cn.quevo.common.enums.ResultStatusEnum;
import cn.quevo.common.exception.CheckParamsException;
import cn.quevo.common.lang.RegularUtils;
import cn.quevo.common.lang.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.beetl.sql.core.annotatoin.Table;

/**
 * 序列索引 实体BEAN
 *
 * @author July july_sky@foxmail.com
 * @version 1.0
 * @date 2019/04/29 21:11:56
 * @Copyright 湘豫（北京）科技有限公司版权所有.All Rights Reserved.
 */
@ApiModel(value = "SequenceIndex 序列索引")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Table(name = "t_sequence_index")
public class SequenceIndex extends DoEntity {

    /** 序列编码 */
    @ApiModelProperty(value = "序列编码")
    private String seqCode;
    /** 序列名称 */
    @ApiModelProperty(value = "序列名称")
    private String seqName;
    /** 序列数量 */
    @ApiModelProperty(value = "序列数量")
    private Integer seqCount;

    /**
    * 公共参数验证
    */
    protected void validate() {
        if(StringUtils.isBlank(this.getSeqCode())){
            throw new CheckParamsException(6001, "序列编码不能为空");
        }
        if(StringUtils.isBlank(this.getSeqName())){
            throw new CheckParamsException(6002, "序列名称不能为空");
        }
        if(StringUtils.isBlank(this.getSeqCount())){
            throw new CheckParamsException(6003, "序列数量不能为空");
        }
    }

    /**
    * 新增参数验证
    */
    public void validateCreate() {
        this.validate();
    }

    /**
    * 修改参数验证
    */
    public void validateUpdate() {
        if (StringUtils.isBlank(this.getId())) {
            throw new CheckParamsException(ResultStatusEnum.RECORD_UNSELECTED);
        }
        this.validate();
    }
}
